Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prioritize pasting files over pasting HTML content #1148

Merged
merged 2 commits into from
Jul 15, 2024
Merged

Prioritize pasting files over pasting HTML content #1148

merged 2 commits into from
Jul 15, 2024

Conversation

afcapel
Copy link
Contributor

@afcapel afcapel commented May 1, 2024

When right clicking and pasting an image the dataTransfer object contains a file and text/html. If we paste the HTML content, the result is often a broken image. This change prioritizes pasting the file over pasting the HTML content.

The gotcha is that when pasting text from MS Word, the dataTransfer object contains a File with a screenshot of the text and text/html with the actual text. We need to check if the paste is from MS Word and if so, we should paste the text instead of the screenshot.

When right clicking and pasting an image the dataTransfer object
contains a file and text/html. If we paste the HTML content, the result
is often a broken image. This change prioritizes pasting the file over
pasting the HTML content.

The gotcha is that when pasting text from MS Word, the dataTransfer object
contains a File with a screenshot of the text and text/html with the
actual text. We need to check if the paste is from MS Word and if so,
we should paste the text instead of the screenshot.
This change prevents duplicate file pastes by checking if the paste event
is a file paste before handling it. This is necessary because Safari
doesn't support `beforeinput.insertFromPaste` for files, so we are handling
file pastes in the paste event handler too.

We need to check in the `beforeinput.insertFromPaste` event handler if the
event will be also handled by the paste event handler, to avoid duplicate
file pastes.
@jeremy jeremy merged commit 831697b into main Jul 15, 2024
1 check passed
@jeremy jeremy deleted the file-pastes branch July 15, 2024 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants